package com.ruoyi.web.controller.chat;

import com.zzy.chattoai.service.ChatService;
import org.springframework.http.codec.ServerSentEvent;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import javax.annotation.Resource;

@RestController
@RequestMapping("/chat")
public class ChatController {


    @Resource
    ChatService chatService;

    @GetMapping("/chatTodeepSeek")
    public String model(@RequestParam(value = "message", defaultValue = "Hello") String message) {

        String chatMode = chatService.chat(message);
        return chatMode;

    }

    @GetMapping("/chatTodeepSeekStream")
    public Flux<ServerSentEvent<String>> chatStream(@RequestParam("memoryId") String memoryId, @RequestParam(value = "message", defaultValue = "Hello") String message) {
        return chatService.chatStream(memoryId, message);

    }

}
